var shopList;
var localData =[
    {"id": 1,"shopName": "户外啥的乱七八糟1","state":1,"phone":15868721752,},
    {"id": 2,"shopName": "户外啥的乱七八糟2","state":0,"phone":15868721752,},
    {"id": 3,"shopName": "户外啥的乱七八糟3","state":1,"phone":15868721752,},
    {"id": 4,"shopName": "户外啥的乱七八糟4","state":1,"phone":15868721752,}
];
$(function () {
    if($('#shopList').length>0){
        shopList = $.fn.bsgrid.init('shopList', {
            localData: localData,   //本地json
            //url:'',               //数据地址
            // autoLoad: false,
            pageSizeSelect: true,
            pageSize: 10,
            stripeRows: true,
            displayBlankRows: false
        });
    }
});
var shop={
    state:function(record, rowIndex, colIndex, options){
        var state=shopList.getRecordIndexValue(record, 'state');
        if(state==1) return '<span class="sui-text-success">有效</span>';
        else if(state==0) return '<span class="sui-text-disabled">失效</span>';
    },
    //表格操作
    operate:function(record, rowIndex, colIndex, options){
        var id=shopList.getRecordIndexValue(record, 'id');
        return '<a href="shopInfo.html?id=' + id + '">编辑</a>';
    },
    //搜索
    search:function(){
        var form=$("#seach").serializeArray();
        shopList.search(form);
    }
}
$(document).on('change','.fileImg',function(e){
    $(this).uploadimg(this,e);
});
$("#shopInfo").validate({
    rules:{
        name:{required:true},
        productId:{required:true},
        proClass:{required:true},
        price:{required:true,number:true},
        phone:{required:true,mobile:true}
    }
});

if($("#teletext").length>0){
    KindEditor.ready(function(k){
        k.create("#teletext");
    });
}
